<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-present http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use cmf\controller\HomeBaseController;
use think\facade\Db;

class IndexController extends HomeBaseController
{
	
	// 首页
	public function index()
	{
		$data = $this->request->param();
		$code = $data['code'] ?? '';
		if($code){
			$code_info = Db::name("agent_code")->where("code='{$code}'")->find();
			if(!$code_info){
				$this->assign("reason", '邀请码不存在');
				
				return $this->fetch('../appapi/error');
			}
		}
		
		$config = getConfigPub();
		$this->assign('agent_code', $code);
		
		return $this->fetch(":index", $config);
	}
	
	public function scanqr()
	{
		return $this->fetch(":scanqr");
	}
	
}

